//根据pid展示信息
//获取pid
var urlobj=new URLSearchParams(location.search);
function changeshow(){
    var id=urlobj.get("pid");
    var html="";
    axios.get(DeltailAPI,{params:{id}}).then(function(res){
        var goods=res.data.data;
        html= `<ul>
        <li><img src="${goods.pimg}" alt="" /></li>
        <li>${goods.pname}</li>
        <li>${goods.pprice}</li>
        <li>${goods.pdesc}</li>
      </ul>`
      $(".addshow").html(html);
      //将内容显示到输入框
      $("input:eq(0)").val(goods.pimg);
      $("input:eq(1)").val(goods.pname);
      $("input:eq(2)").val(goods.pprice);
      $("input:eq(3)").val(goods.pdesc);
    })
}
changeshow();
/* //   pid（必选）商品的id
pname（必选）商品
pprice（必选）商品
pdesc（必选）商品 */
console.log(("button"));
$("button").click(function(){
    var pimg=$("input:eq(0)").val();
    var pname=$("input:eq(1)").val();
    var pprice=$("input:eq(2)").val();
    var pdesc=$("input:eq(3)").val();
    var pid=urlobj.get("pid");
    axios.get(ChangeAPI,{params:{pimg,pname,pprice,pdesc,pid}}).then(function(res){
        alert(res.data.msg);
        changeshow();
    })
})
$(".back").click(function(){
    location.href="home.html";
})